﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using Sail.Localization;

namespace Sail
{
    /// <summary>
    /// 异常对象
    /// </summary>
    [Serializable]
    public class SailCoreException : Exception
    {
        private readonly LocalizedString localizedMessage;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message">本地化消息</param>
        public SailCoreException(LocalizedString message)
            : base(message.Text)
        {
            localizedMessage = message;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message">本地化消息</param>
        /// <param name="innerException">异常对象</param>
        public SailCoreException(LocalizedString message, Exception innerException)
            : base(message.Text, innerException)
        {
            localizedMessage = message;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="info">SerializationInfo对象</param>
        /// <param name="context">StreamingContext对象</param>
        protected SailCoreException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        /// <summary>
        /// 本地化信息
        /// </summary>
        public LocalizedString LocalizedMessage
        {
            get { return localizedMessage; }
        }
    }
}